﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

public partial class CusDeliveryInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        LableUserName.Text=Request.QueryString["Name"];

        LableTotalPaid.Text=Request.QueryString["Total"];
    
    }
   
    protected void Button2_Click(object sender, EventArgs e)
    {

        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString);
        con.Open();
        string insCmd = "Insert into DateDelivery(CustomerName, AmountPaid, DeliveryAddress, DateDelivery,DeliverTime) values (@CustomerName,@AmountPaid,@DeliveryAddress,@DateDelivery,@DeliverTime)";
        SqlCommand insertUser = new SqlCommand(insCmd, con);
        insertUser.Parameters.AddWithValue("@CustomerName", LableUserName.Text);
        insertUser.Parameters.AddWithValue("@AmountPaid", LableTotalPaid.Text);
        insertUser.Parameters.AddWithValue("@DeliveryAddress", TextDeliveryAddress.Text);
        insertUser.Parameters.AddWithValue("@DateDelivery", LableDateDelivery.Text);
        insertUser.Parameters.AddWithValue("@DeliverTime", DropDownListDate.SelectedItem.ToString());



        try
        {
            insertUser.ExecuteNonQuery();
            con.Close();
            Response.Redirect("thank.aspx"); 


        }

        catch (Exception ex)
        {
            if (ex is SqlException)
            {
                Response.Write("<b>Something Really Bad Happened...Please try Again.</b>");
            }
        }
        finally
        {
            //Any Special Action you want to Add.........
        }

    }

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        DateTime startD;
        Label4.Text = "";
        startD = Calendar1.SelectedDate;

        if (startD > DateTime.Now.Date)
            LableDateDelivery.Text = startD.ToString("d");
        else
        {
            Label4.Text = "Please select at lease 1 day ahead";

        }   
    }
}